const express = require('express');
const UserModel = require('../../model/userModel');
const md5 = require('md5');

const router = express.Router();


//创建路由
router.get('/reg', (req, res) => {
    res.render('auth/auth');
})

router.post('/reg', (req, res) => {



    UserModel.create({ ...req.body, password: md5(req.body.password) }).then((data) => {
        console.log('注册成功');

    }).catch(error => {
        console.log(error.message);

        return;
    })



    res.render('success', { message: '注册成功', url: '/login' })

})

//导入模块
module.exports = router;
